#pragma once

#include <windows.h>
#include <string>
#include "Window.h"
#include "Thread.h"
#include <iostream>

struct float3{
	float3(float px,float py,float pz):x(px),y(py),z(pz){}
	float x,y,z;
};

struct float2{
	float2(float pu, float pv):u(pu),v(pv){}
	float u,v;
};

/**
* An object that encapsulates an OpenGL window.
* @author Koen Samyn
*/
class OpenGLWindow: public Window,public IRunnable
{
public:
	/**
	* Creates a new OpenGLWindow with the provided title.
	* @param title the title of the OpenGL window.
	* @param width the width of the OpenGL window.
	* @param height the height of the OpenGL window.
	*/
	OpenGLWindow(std::wstring title,unsigned int width, unsigned int height);
	/**
	* Destroys the OpenGLWindow.
	*/
	virtual ~OpenGLWindow(void);
	/**
	* Initializes the open gl window.
	*/
	bool Init();
	/** 
	* Creates the opengl window.
	*/ 
	bool Create();
	/**
	* Repaints the window.
	*/
	void Repaint();
	/**
	* Kills this OpenGL window.
	* @return true if releasing every resource was succesful.
	*/
	bool Kill();
	/**
	* Resize the open gl window.
	* @param width the new width of the open gl window.
	* @param height the new height of the open gl window.
	*/
	void Resize(unsigned int width, unsigned int height);
	/**
	* Draws a grid
	*/
	void DrawGrid(int numberOfLines, float gridSize);
	/**
	* Draw the open gl window.
	*/
	void Draw();
	
	/**
	* A key pressed event was received.
	* @param key the character that was pressed.
	*/ 
	virtual void KeyPressed(int keyCode){}
	/**
	* A key released event was received.
	* @param key the character that was released.
	*/
	virtual void KeyReleased(int keyCode){}
	/**
	* Called when a key was typed. This can be a combination of several keys (for example shift + a = 'A',
	* , ALT GR + '2' = '@'
	*/
	virtual void KeyTyped(wchar_t keyCode){}

	void Run();
private:
	/**
	* The bitdepth for the window.
	*/
	unsigned int m_Bits;

	Thread* m_pPaintThread;
	bool m_Running;
};

